package ar.activity;

import java.util.ArrayList;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;
import android.widget.TextView;
import ar.view.adapter.ShareChooseFriendAdapter;

public class ShareChooseFriendActitvity extends BaseActivity {

	private ListView lvShareChooseFriend;
	private ShareChooseFriendAdapter adapter;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
		setContentView(R.layout.share_choose_friend);
		super.onCreate(savedInstanceState);
		tvWhatScreen.setText("Choose a friend");

		Intent i = getIntent();
		ArrayList<String> srcNames = i.getStringArrayListExtra("srcNames");
		ArrayList<String> srcNumbers = i.getStringArrayListExtra("srcNumbers");

		adapter = new ShareChooseFriendAdapter(this);
		adapter.setSrcNames(srcNames);
		adapter.setSrcNumbers(srcNumbers);

		lvShareChooseFriend = (ListView) findViewById(R.id.lvShareChooseFriend);
		lvShareChooseFriend.setAdapter(adapter);
		lvShareChooseFriend.setOnItemClickListener(new OnItemClickListener() {

			@Override
			public void onItemClick(AdapterView<?> arg0, View v, int position,
					long id) {
				View row = lvShareChooseFriend.getChildAt(position);
				TextView tvMain = (TextView) row
						.findViewById(R.id.tvShareChooseFriendMain);
				TextView tvSub = (TextView) row
						.findViewById(R.id.tvShareChooseFriendSub);
				Intent i = new Intent();
				i.putExtra("name", tvMain.getText());
				i.putExtra("number", tvSub.getText());
				setResult(RESULT_OK, i);
				finish();
			}
		});
	}

}
